package com.hccl.sluentities;;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Reference;

import java.util.ArrayList;
import java.util.List;

@Entity(value = "command", noClassnameStored = true)
public class Command {

    @Id
    protected ObjectId id;
    protected boolean ordered;
    protected String name;
    @Embedded
    protected List<RuleEntryEntity> lists = new ArrayList<RuleEntryEntity>();
    @Reference(idOnly=true,lazy=true)
    protected List<GrammarRuleEntity> rules = new ArrayList<GrammarRuleEntity>();

    public Command(){

    }
    public Command(
                   @JsonProperty("name") String name) {
        this.name = name != null ? name : "";
    }

    public List<GrammarRuleEntity> getRules() {
        return rules;
    }

    public void setRules(List<GrammarRuleEntity> rules) {
        this.rules = rules;
    }

    public ObjectId getId() {
        return id;
    }

    public void setId(ObjectId id) {
		this.id = id;
	}
	
	public boolean getOrdered(){return ordered;}

    public void setOrdered(boolean ordered){this.ordered=ordered;}
	
    public String getName() {
        return name;
    }

    public void setName(String content) {
        this.name = content;
    }
	
	public void setLists(List<RuleEntryEntity> lists) {
        this.lists = lists;
    }

    public List<RuleEntryEntity> getLists() {
        return lists;
    }
}
